<template>
	<div class="safety_loop_detail">
		<div class="safety_loop">
			<span class="safety_loop_li">
				<img :src="shareImg">
				<div class="img_wrap">
					<span class="head" v-if="safetyMeetingDetailTopData.empImg">
						<img :src="safetyMeetingDetailTopData.empImg">
					</span>
					<span class="head" v-else="safetyMeetingDetailTopData.empImg">
						<img src="../../assets/img/head_img.jpg">
					</span>
					<span class="iflike" :class="[safetyMeetingDetailTopData.ifLike? 'ion_heart_red' : 'ion_heart_default']" @click="thumbsUp"></span>
					<h3>{{safetyMeetingDetailTopData.shareTitle}}</h3>
				</div>
				
				<p class="author">by {{safetyMeetingDetailTopData.empName}}</p>
				<footer class="foot clearFix">
					<span class="time"><i class="ion ion-android-time"></i>{{safetyMeetingDetailTopData.shareTime}}</span>
					<span class="like"><i class="ion ion-ios-heart-outline"></i> {{safetyMeetingDetailTopData.likeCount}}</span>
					<span class="classify"><i class="icon_mark"></i>{{safetyMeetingDetailTopData.dataTypeText}}</span>
				</footer>
			</span>
		</div>

		<div class="article_con">
			<!-- <article class="con">
				<h4><i class="icon_disk blue_disk ion ion-ios-information-empty"></i>基本信息</h4>
				<p>时间：{{safetyMeetingContentData.meetingTime}}</p>
				<p>地点：{{safetyMeetingContentData.meetingSite}}</p>
				<p>主持人：{{safetyMeetingContentData.emccName}}</p>
				<p>记录人：{{safetyMeetingContentData.rememberName}}</p>
			</article> -->
			<article class="con">
				<h4 class="blue"><i class="icon_disk orange_disk ion ion-person"></i>参加人员</h4>
				<!-- <p><span v-for="emp of meetingEmp">{{emp.empName}},</span></p> -->
				<p>{{meetingEmp || '暂无'}}</p>
			</article>
			<article class="con">
				<h4><i class="icon_disk lightgreen_disk icon_image"></i>相关照片</h4>
				<p><img v-if="meetingImgs.length > 0" v-for="img of meetingImgs" :src="img"></p>
			</article>
			<article class="con">
				<h4><i class="icon_disk yellow_disk ion ion-android-star-outline"></i>相关事项</h4>
				<h5>上次会议整改行动回顾(如有):</h5>
				<p v-html="safetyMeetingContentData.modifyLast || '暂无'"></p>
				<h5>案例分析/险性事故分享:</h5>
				<p v-html="safetyMeetingContentData.modifyComment || '暂无'"></p>
				<h5>存在的问题及改进:</h5>
				<p v-html="safetyMeetingContentData.modifyPlan || '暂无'"></p>
			</article>

		</div>

	</div>
</template>
<script type="text/javascript">
	import getInterface from '../../assets/js/insterface.js'
	import PreviewImg from '../../assets/js/previewImg'

	export default{
		data(){
			return{
				safetyMeetingDetailUrl:getInterface.getsafetyMeetingDetailUrl,
				safetyMeetingDetailTopData:'',
				safetyMeetingContentData:'',
				meetingImgs:[],
				meetingEmp:'',
				shareImg:''
			}
		},
		mixins:[PreviewImg],
		mounted(){
			this.$el.parentElement.parentNode.style.background = '#fafafa';
			document.title="会议纪要";
			this.getsafetyMeetingDetailData();
			let vue = this;
			setTimeout(()=>{
				vue.readImgInfo();
			},1100)
		},
		methods:{
			getsafetyMeetingDetailData(){
				// let param ={
				// 	id:this.$route.query.id,
				// 	empNo:this.$route.query.empNo
				// }

				this.$http.get(this.safetyMeetingDetailUrl+ this.$route.query.id +"/"+ this.$route.query.empNo,{emulateJSON: true})
				.then((response) => {
					console.log(response)
					let resData= response.data;
					this.safetyMeetingDetailTopData = resData.topData;
					this.safetyMeetingContentData = resData.contentData.smVo;

					this.shareImg = resData.topData.shareImg.split(',')[0];

					this.safetyMeetingContentData.modifyLast = this.safetyMeetingContentData.modifyLast.replace(/\r\n|\n/g,'<br/>');
					this.safetyMeetingContentData.modifyComment = this.safetyMeetingContentData.modifyComment.replace(/\r\n|\n/g,'<br/>');
					this.safetyMeetingContentData.modifyPlan = this.safetyMeetingContentData.modifyPlan.replace(/\r\n|\n/g,'<br/>');


					this.safetyMeetingDetailTopData.shareTime = resData.topData.shareTime.substring(0,10);

					let shareImg = resData.topData.shareImg;
					if(shareImg.indexOf(',') !=-1){
						resData.topData.shareImg = shareImg.substring(0,shareImg.indexOf(','));
					}

					this.safetyMeetingDetailTopData.ifLike = parseInt(resData.topData.ifLike);
					/*if(response.data.topData.empImg == ''){
							this.safetyMeetingDetailTopData.empImg = require('../../assets/img/head_img.jpg)'
						}*/
					switch(resData.topData.dataType){
						case 0:
							this.safetyMeetingDetailTopData.dataTypeText = 'NM'
							break;
						case 1:
							this.safetyMeetingDetailTopData.dataTypeText = 'safe to go'
							break;
						case 2:
							this.safetyMeetingDetailTopData.dataTypeText = 'safety meeting'
							break;
						case 3:
							this.safetyMeetingDetailTopData.dataTypeText = 'SOC'
							break;
					};
					if(resData.contentData.smVo.meetingImg !=""){
						this.meetingImgs = response.data.contentData.smVo.meetingImg.split(',');
					}

					let meetingEmps = [];

					for(let emp of resData.contentData.meetingEmpArr){
						meetingEmps.push(emp.empName);
					}
					this.meetingEmp = meetingEmps.join()
				})
			},
			thumbsUp(){
				if(this.safetyMeetingDetailTopData.ifLike=="0"){
			    	let params = {id:this.safetyMeetingDetailTopData.relationId,empNo:this.$route.query.empNo}
			    	this.$http.post(getInterface.isPraiseUrl,params,{emulateJSON: true})
			    	.then((response) => {
			    		console.log(response)			    		
		    			if(response.data.type == "2"){
		    				console.log("点赞成功！")
					      	this.safetyMeetingDetailTopData.ifLike = 1;
					      	if(this.safetyMeetingDetailTopData.likeCount == undefined || this.safetyMeetingDetailTopData.likeCount == null){
					      		this.safetyMeetingDetailTopData.likeCount = 0;
					      	}
					      	this.safetyMeetingDetailTopData.likeCount++;
				        }else{
				      	    console.log("点赞失败！")
				        }					
			    	})
			    	.catch(function(response){
			    		console.log(response)
			    	})
		    	}else{
			    	console.log("您已点过赞！")
			    }
		    }
		}
	}
</script>